package com.persagy.service.quartz;

import java.util.List;

import org.quartz.SchedulerException;

import com.persagy.ems.pojo.quartz.JobErrorLog;
import com.persagy.ems.pojo.quartz.ScheduleJob;

public interface ScheduleJobService {

	/**
	 * 查询数据库job任务
	 * 
	 * @param job
	 * @return
	 * @throws Exception
	 */
	public List<ScheduleJob> getJobList(ScheduleJob job) throws Exception;

	/**
	 * 添加任务
	 * 
	 * @param job
	 * @return
	 * @throws Exception
	 */
	public int insertJob(ScheduleJob job) throws Exception;

	/**
	 * 更新任务调度时间
	 * 
	 * @param job
	 * @return
	 * @throws Exception
	 */
	public int updateJob(ScheduleJob objectCriteria, ScheduleJob objectUpdate) throws Exception;


	/**
	 * 启动定时任务
	 * 
	 * @param job
	 * @param jobAction
	 * @throws Exception
	 */
	public void startJob(ScheduleJob job) throws Exception;

	/**
	 * 获取计划中全部任务
	 * 
	 * @return
	 * @throws Exception
	 */
	public List<ScheduleJob> getScheduleJobs() throws Exception;

	/**
	 * 获取运行中的任务
	 * 
	 * @return
	 * @throws Exception
	 */
	public List<ScheduleJob> getRunningJobs() throws Exception;

	/**
	 * 暂停任务
	 * 
	 * @param job
	 * @throws Exception
	 */
	public void pauseJob(ScheduleJob job) throws Exception;

	/**
	 * 恢复任务
	 * 
	 * @param job
	 * @throws Exception
	 */
	public void resumeJob(ScheduleJob job) throws Exception;

	/**
	 * 删除任务
	 * 
	 * @param job
	 * @throws Exception
	 * @throws Exception 
	 */
	public int deleteJob(ScheduleJob job) throws Exception;

	/**
	 * 立刻触发job运行
	 * 
	 * @param job
	 * @throws Exception
	 */
	public void triggerJob(ScheduleJob job) throws Exception;
	
	/**
	 * 添加错误日志
	 * 
	 * @param job
	 * @throws Exception
	 */
	public void insertErrorLog(JobErrorLog error);
	
	/**
     * 核查job是否已经被初始化
     * 存在 true
     * 存在 false
     * @param schedulerName
     * @param jobName
     * @param jobGroup
     * @return
     * @throws SchedulerException
     */
    public boolean isJobRegister(ScheduleJob job) throws Exception;
    
    /**
     * 判断job是否存在
     * @param job
     * @return
     * @throws Exception
     */
    public boolean isJobExists(ScheduleJob job) throws Exception;

}
